﻿// ShareFolderTest.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

#include "../../ShareFolder/ShareFolder.h"

#include <Lmcons.h>




//#pragma comment(lib, "netapi32.lib")
//
//#include <stdio.h>
//#include <windows.h> 
#include <lm.h>
//#include <vector>
#include <Winnetwk.h>
#pragma comment(lib, "mpr.lib")

int main()
{
	
	TCHAR * pszAccountName = _T("AAA");
	TCHAR * pszPassword = _T("123456");
	TCHAR * pszOldPassword = _T("123456");
	bool bRes = false;
	std::wstring strErr;

	std::wstring strRemoteSharePath = _T("\\\\WIN-07PJMR8PJT7\\a");

	// 获取系统名称
	TCHAR szComputerNameBuffer[512] = { 0 };
	DWORD dwCNBufLen = 512;
	GetComputerName(szComputerNameBuffer, &dwCNBufLen);

	int iRes = _taccess(_T("\\\\192.168.1.241\\docs"), 0);

	//bRes = ShareFolder::AddNetworkDriver(_T("Y:"), _T("\\\\192.168.1.241\\docs"), _T("root"), _T("abcd1234"));

	//bRes = ShareFolder::ShowShareLogonDlgEx((TCHAR*)strRemoteSharePath.c_str(), pszAccountName, pszPassword);
	//ShareFolder::ShowShareLogonDlg(_T("\\\\WIN-07PJMR8PJT7\\a"));
	

	

	std::vector<std::pair<std::wstring, std::wstring>> shareVec;
	bRes = ShareFolder::EnumLocalShare(shareVec);

	std::vector<std::pair<std::wstring, std::wstring>> localRemoteNameVec;
	bRes = ShareFolder::GetRemoteDisk(localRemoteNameVec, strErr);

	std::vector<std::pair<std::wstring, std::wstring>> localRemoteNameVec2;
	bRes = ShareFolder::EnumNetworkDriver(localRemoteNameVec2);

	std::vector<std::wstring> accountVec;
	bRes = UserManager::EnumAccount(accountVec);
	//bRes = UserManager::DelAccount(pszAccountName);
	//bRes = UserManager::AddAccount(pszAccountName, pszOldPassword);
	bRes = UserManager::ChangeAccountPassword(pszAccountName, pszOldPassword, pszPassword);
	//bRes = UserManager::AddAccountToGroup(pszAccountName, _T("Administrators"));


	TCHAR * pszSharePath = _T("E:QT_DATA");
	TCHAR * pszShareName = _T("QT_DATA");
	
	bRes = ShareFolder::DelShare(pszShareName);
	bRes = ShareFolder::SetShare(pszSharePath, pszShareName);
	//bRes = ShareFolder::SetShare(pszSharePath, pszShareName, _T("Everyone"));

	TCHAR szNameBuffer[512] = { 0 };
	DWORD dwNameLen = 512;
	::GetUserName(szNameBuffer, &dwNameLen);
	//bRes = ShareFolder::EnableFileAccountPrivilege(_T("D:\\c"), szNameBuffer);
	bRes = ShareFolder::EnableFileAccountPrivilege(pszSharePath, pszAccountName);
	bRes = ShareFolder::EnableFileAccountPrivilege(pszSharePath, _T("Everyone"));

	//_T("anonymous");






	system("pause");
    return 0;
}

